package cn.zero.flowspringbootstater.service;



import cn.zero.flowspringbootstater.modular.bean.GeneralException;
import cn.zero.flowspringbootstater.modular.bean.FlowErrorException;
import cn.zero.flowspringbootstater.modular.entity.Flow;
import cn.zero.flowspringbootstater.modular.vo.*;
import cn.zero.flowspringbootstater.utils.function.BranchHandler;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;

import java.util.List;
import java.util.Set;

/**
 * <p>
 * 审批流程 服务类
 * </p>
 *
 * @author lei
 * @since 2022-06-17
 */
public interface IFlowService extends IService<Flow> {

    /**
     * 流程审批
     * @param dto:  审批参数
     * @return: BranchHandler 携带操作审批后置操作
     * @author: lei
     */

    public BranchHandler approvalFunc(FlowApprovalDto dto)  throws FlowErrorException;

    /**
     * 流程审批
     * @param dto:  审批参数
     * @return: FlowApprovalRes 审批结果
     * @author: lei
     */

    public FlowApprovalRes approval(FlowApprovalDto dto) throws GeneralException, FlowErrorException;

    /**
     * 绑定/重新发起业务审批流程
     * @param dto:
     * @return: cn.ygkj.system.api.dto.FlowApprovalRes
     * @author: lei
     */

    public FlowBindRes bindFlow(FlowBindDto dto) throws FlowErrorException;


    /**
     * 获取业务数据的审批状态
     * @param businessId:
     * @return: cn.ygkj.system.api.dto.FlowApprovalRes
     * @author: lei
     */

    public FlowApprovalRes flowState(String businessId);

    /**
     * 编辑流程
     * @param flowParamVo
     * @return java.lang.Long
     * @author lei
     */

    public Long editFlow(FlowParamVo flowParamVo) throws FlowErrorException;


    /**
     * 查询审批流程的审批节点和审批状态详情
     * @param flowId: 流程id
     * @param businessId: 业务id
     * @return: void
     * @author: lei
     */

    FlowBusinessVo getFlowNodeDetail(String flowId, String businessId);

    /**
     * 查询流程列表
     * @param flow:
     * @return: java.util.List<cn.ygkj.system.entity.Flow>
     * @author: lei
     */

    Page<Flow> selectFlowList(Flow flow, Integer pageSize, Integer pageNum);

    /**
     * 获取流程的详情
     *
     * @param id 流程id
     * @return: cn.ygkj.logistics.common.core.utils.Result
     * @author: lei
     */

    public List<FlowParamVo> getFlowDetail(Long id) throws FlowErrorException;

    /**
     * 通过业务id查询当前节点的审核权限用户id
     * @param businessId 业务id
     * @return java.util.List<java.lang.Long>
     * @author lei
     */
    List<FlowNode2UserVo> getHasRoleUserIdByBusinessId(Set<String> businessId);

    /**
     * 重置审批流程
     * @param businessId
     * @param flowId
     * @return void
     * @author lei
     */

    Boolean resetFlow(String businessId, Long flowId) throws FlowErrorException;
    /**
     * 回滚至此业务的上一步，若从已经审批的中间开始回滚，将回滚至{ nodeId }的上一步
     * @param businesId 业务id
     * @param nodeId 当前的节点id
     * @return cn.ygkj.common.core.model.Result<java.lang.Boolean>
     * @author lei
     */
    Boolean rollbackPrevious(String businesId, Long flowId, Long nodeId);
}
